import java.util.*;

class Solution692_3 {
    public static void main(String[] args) {
        Integer a = 1 ;
        Integer b = 2 ;
        System.out.println(a.compareTo(b));
        List<Integer> list  = new ArrayList<>() ;

    }
    public static List<String> topKFrequent(String[] words, int k) {
        Map<String,Integer> map = new HashMap<>() ;
        Set<String> set = new HashSet<>() ;
        for(String str : words){
            map.put(str, map.getOrDefault(str,0)+1) ;
            set.add(str) ;
        }
        PriorityQueue<String> queue = new PriorityQueue<String>(
                (o1 , o2)->{
                    int ret =   map.get(o1).compareTo(map.get(o2)) ;
                    if(ret != 0 )return ret ;
                    return o2.compareTo(o1) ;
                }
        );
        
        for(int i=0 ; i < words.length ; i ++){
            String ret =words[i] ;
            if(set.contains(ret)){
                if(queue.size() < k){
                    queue.add(ret) ;
                }else{
                    String b = queue.peek() ;
                    if(map.get(ret) > map.get(b)){
                        queue.poll() ;
                        queue.add(ret) ;
                    }else if(map.get(ret) .equals(map.get(b))){
                        if(ret.compareTo(b)< 0 ){
                            queue.poll() ;
                            queue.add(ret) ;
                        }
                    }
                }
                set.remove(ret) ;
            }
        }
        List<String> list = new ArrayList<>() ;
        while(!queue.isEmpty()){
            list.add(queue.poll()) ;
        }
        Collections.reverse(list) ;
        return list ;

    }
}